package com.google.guava.eventbus.monitor;

import com.google.common.eventbus.EventBus;

import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

/**
 * @author fuc
 * @create 2020-10-06
 */
public class MonitorClient {
  public static void main(String[] args) throws Exception {
    final EventBus eventBus = new EventBus();
    eventBus.register(new FileChangeListener());
    TargetMonitor monitor = new DirectoryTargetMonitor(eventBus, "");
    Executors.newSingleThreadScheduledExecutor()
        .schedule(
            () -> {
              try {
                monitor.stopMonitor();
              } catch (Exception e) {
                e.printStackTrace();
              }
            },
            2,
            TimeUnit.MINUTES);
    monitor.startMonitor();
  }
}
